# coding:utf-8
__author__ = 'Helen'
'''
description:driver配置
'''
from appium import webdriver
from config.usersetting import *

class configure():
    def get_driver(self):
        '''获取driver'''
        try:
            desired_caps = {}
            desired_caps['platformName'] = platform  # 平台
            desired_caps['platformVersion'] = platformVersion  # 系统版本
            # self.desired_caps['app'] = app_path   # 指向.apk文件，如果设置appPackage和appActivity，那么这项会被忽略

            desired_caps['automationName'] = automationName
            desired_caps['appPackage'] = app_package
            desired_caps['appActivity'] = appActivity
            # desired_caps['unicodeKeyboard'] = 'true'  # 是否支持unicode的键盘。如果需要输入中文，要设置为“true”
            # desired_caps['resetKeyboard'] = 'true'  # 是否在测试结束后将键盘重轩为系统默认的输入法。
            # self.desired_caps[' # Appium服务器待appium客户端发送新消息的时间。默认为60秒
            desired_caps['deviceName'] = deviceName  # 手机ID
            # self.desired_caps['noReset'] = True  # true:不重新安装APP，false:重新安装app
            print("http://" + devHost + ":" + devPort + "/wd/hub")
            driver = webdriver.Remote("http://"+devHost+":"+devPort+"/wd/hub", desired_caps)

            return driver
        except Exception as e:
            raise e